﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.2.1    出纳收支信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_FIN_INCOME: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_FIN_INCOME()
		{}
		#region Model
		private long _id;
		private long _pid;
		private int _incometype;
		private string _accountname;
		private long _accountid;
		private decimal _amt;
		private Nullable<DateTime> _tallydate;
		private decimal _inamt;
		private decimal _outamt;
		private decimal _leftamt;
		private string _summary;
		private string _remark;
		private string _createby;
		private Nullable<DateTime> _createdate;
		private int _systemid;
		/// <summary>
		/// 记录ID唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 父表记录ID
		/// </summary>
		[DataMember]
		public long PID
		{
			get{return _pid;}
			set{
				if ( _pid!= value)
				{
					 _pid = value;
					OnPropertyChanged("PID");
				}
			}
		}
		/// <summary>
		/// 类别1预收款，2收回,0其他
		/// </summary>
		[DataMember]
		public int INCOMETYPE
		{
			get{return _incometype;}
			set{
				if ( _incometype!= value)
				{
					 _incometype = value;
					OnPropertyChanged("INCOMETYPE");
				}
			}
		}
		/// <summary>
		/// 银行账户
		/// </summary>
		[DataMember]
		public string ACCOUNTNAME
		{
			get{return _accountname;}
			set{
				if ( _accountname!= value)
				{
					 _accountname = value;
					OnPropertyChanged("ACCOUNTNAME");
				}
			}
		}
		/// <summary>
		/// 银行账户记录ID
		/// </summary>
		[DataMember]
		public long ACCOUNTID
		{
			get{return _accountid;}
			set{
				if ( _accountid!= value)
				{
					 _accountid = value;
					OnPropertyChanged("ACCOUNTID");
				}
			}
		}
		/// <summary>
		/// 原余额
		/// </summary>
		[DataMember]
		public decimal AMT
		{
			get{return _amt;}
			set{
				if ( _amt!= value)
				{
					 _amt = value;
					OnPropertyChanged("AMT");
				}
			}
		}
		/// <summary>
		/// 记账时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> TALLYDATE
		{
			get{return _tallydate;}
			set{
				if ( _tallydate!= value)
				{
					 _tallydate = value;
					OnPropertyChanged("TALLYDATE");
				}
			}
		}
		/// <summary>
		/// 收入
		/// </summary>
		[DataMember]
		public decimal INAMT
		{
			get{return _inamt;}
			set{
				if ( _inamt!= value)
				{
					 _inamt = value;
					OnPropertyChanged("INAMT");
				}
			}
		}
		/// <summary>
		/// 支出
		/// </summary>
		[DataMember]
		public decimal OUTAMT
		{
			get{return _outamt;}
			set{
				if ( _outamt!= value)
				{
					 _outamt = value;
					OnPropertyChanged("OUTAMT");
				}
			}
		}
		/// <summary>
		/// 结余
		/// </summary>
		[DataMember]
		public decimal LEFTAMT
		{
			get{return _leftamt;}
			set{
				if ( _leftamt!= value)
				{
					 _leftamt = value;
					OnPropertyChanged("LEFTAMT");
				}
			}
		}
		/// <summary>
		/// 摘要
		/// </summary>
		[DataMember]
		public string SUMMARY
		{
			get{return _summary;}
			set{
				if ( _summary!= value)
				{
					 _summary = value;
					OnPropertyChanged("SUMMARY");
				}
			}
		}
		/// <summary>
		/// 备注
		/// </summary>
		[DataMember]
		public string REMARK
		{
			get{return _remark;}
			set{
				if ( _remark!= value)
				{
					 _remark = value;
					OnPropertyChanged("REMARK");
				}
			}
		}
		/// <summary>
		/// 记录人
		/// </summary>
		[DataMember]
		public string CREATEBY
		{
			get{return _createby;}
			set{
				if ( _createby!= value)
				{
					 _createby = value;
					OnPropertyChanged("CREATEBY");
				}
			}
		}
		/// <summary>
		/// 记录时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CREATEDATE
		{
			get{return _createdate;}
			set{
				if ( _createdate!= value)
				{
					 _createdate = value;
					OnPropertyChanged("CREATEDATE");
				}
			}
		}
		/// <summary>
		/// 来源信贷、典当、租赁、新增
		/// </summary>
		[DataMember]
		public int SYSTEMID
		{
			get{return _systemid;}
			set{
				if ( _systemid!= value)
				{
					 _systemid = value;
					OnPropertyChanged("SYSTEMID");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

